<script type="text/javascript" >
 	<fmt:message key="LoginError" var="loginError"/>   
 	var loginErrorMessage = "${loginError}";
 	
 	<fmt:message key="PasswordError" var="passwordError"/>
 	var passwordErrorMessage = "${passwordError}";
 	
 	<fmt:message key="PasswordNotMayBeEmpty" var="passwordNotMayBeEmpty"/>
 	var passwordNotMayBeEmptyMessage = "${passwordNotMayBeEmpty}";
 	
 	function trim(str) {
        return str.replace(/^\s+|\s+$/g,"");
	}	

	function validate() {
		
		var username_regex = /^[\w.-]+$/;
	    var validLogin = username_regex.test(document.getElementById("login").value);
	    
	    if (!validLogin)
	    {
	    	alert(loginErrorMessage);
	    	return false;
	    }
	    
	    var passwordStr = document.getElementById("password").value;
	    if (trim(passwordStr) == "")
	    {
	    	alert(passwordNotMayBeEmptyMessage);
	    	return false;
	    }
	    	    
	    var passwordConfirmStr = document.getElementById("passwordConfirm").value;
	    if (passwordStr != passwordConfirmStr)
	    {
	    	alert(passwordErrorMessage);
	    	return false;	
	    }
	    
	    return true;
	}
</script>	

<c:set var="view" value="registration" scope="session"/>
<form id="registrationForm" name="frm" method="post" action="checkRegistration" onsubmit='return validate(this);'>
<table id="registrationTable">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td><fmt:message key="Login" /></td>
    <td><input id="login" type="text" name="login" ></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><fmt:message key="Password" /></td>
    <td><input id="password" type="password" name="password" ></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><fmt:message key="PasswordConfirm" /></td>
    <td><input id="passwordConfirm" type="password" name="passwordConfirm" ></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input align="center" type="submit" name="submit" value="Submit"></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>

